//
//  HJRecaptchaClient.m
//  KaiChat
//
//  Created by lx on 2024/1/11.
//

#import "HJRecaptchaClient.h"
#import <RecaptchaEnterprise/RecaptchaEnterprise.h>



@interface HJRecaptchaClient()

@property (strong, atomic) RecaptchaClient *recaptchaClient;

@end


@implementation HJRecaptchaClient
//6Lc6llgpAAAAAE1hgl-O2pzVOKP7_c3Q8XRcKDsG 测试环境
+ (void)recaptchaClientVerifyComplete:(void (^)(NSString * _Nullable token, NSError * _Nullable error))complete {
    
    [Recaptcha getClientWithSiteKey:getRecaptchaKey()
                         completion:^void(RecaptchaClient* recaptchaClient, NSError* error) {
        NSLog(@"getClientWithSiteKeyerror = %@", error);
        if (error) {
            complete(nil, error);
            return;
        }
        
        [recaptchaClient execute:RecaptchaAction.login
                      completion:^void(NSString* _Nullable  token, NSError* _Nullable executeError) {
            
            NSLog(@"executeError = %@, token = %@", executeError, token);

            if (executeError) {
                complete(nil, executeError);
                return;
            }
            complete(token, nil);
        }];
    }];
}

@end
